package strings;

import java.util.HashMap;
import java.util.Map;

/**
 * @author pengfei.hpf
 * @date 2020/3/19
 * @verdion 1.0.0
 */
public class BuildLongestPalindrome {
    public int longestPalindrome(String s) {
        if(s == null || s.length() == 0){
            return 0;
        }
        int[] count = new int[128];
        for (char c: s.toCharArray()){
            count[c]++;
        }

        int total = 0;
        for(int i: count){
            if(i %2 == 0){
                total += i;
            } else {
                total += i - 1;
            }
        }
        if(total < s.length()){
            total ++;
        }
        return total;
    }
}
